package com.vectz.mgt;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.HeadlessException;
import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.SwingConstants;

import com.ait.lsp.msm.ui.decorator.component.DefaultLabel;
import com.ait.lsp.msm.ui.decorator.component.button.DefaultButton;
import com.ait.lsp.msm.ui.decorator.container.DefaultDialog;
import com.ait.lsp.msm.ui.decorator.container.DefaultPanel;
import com.ait.lsp.msm.ui.decorator.util.SwingUtil;

/**
 * @author ai-t.vn
 * 
 */
public class AboutBox extends DefaultDialog {
	private DefaultPanel pnlAbout = new DefaultPanel();
	private DefaultPanel pnlPicture = new DefaultPanel();
	private DefaultPanel pnlContent = new DefaultPanel();
	private DefaultPanel pnlButton = new DefaultPanel();
	private DefaultButton btnClose = new DefaultButton();
	private FlowLayout layoutButton = new FlowLayout();
	private DefaultLabel lblPicture = new DefaultLabel();
	private DefaultLabel lblLSPMSM = new DefaultLabel();
	private DefaultLabel lblNTTAT = new DefaultLabel();
	private DefaultLabel lblAddress = new DefaultLabel();
	private GridBagLayout layoutContent = new GridBagLayout();
	private FlowLayout layoutPicture = new FlowLayout();
	private BorderLayout layoutAbout = new BorderLayout();
	private BorderLayout layoutThis = new BorderLayout();

	// ------------------------------------------------------------------------------
	public AboutBox() throws HeadlessException {
		jbInit();
	}

	private void jbInit() {
		setTitle("About Master Maintenance Generate System");
		this.getContentPane().setLayout(layoutThis);
		pnlAbout.setLayout(layoutAbout);
		btnClose.setHorizontalAlignment(SwingConstants.CENTER);
		btnClose.setText("OK");
		btnClose.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
		btnClose.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
		// AnhDV add 2008-07-09
		// Press Enter to call btnClose
		btnClose.setVerifyInputWhenFocusTarget(true);

		pnlButton.setLayout(layoutButton);
		layoutButton.setAlignment(FlowLayout.RIGHT);
		pnlPicture.setLayout(layoutPicture);
		pnlContent.setLayout(layoutContent);

		lblLSPMSM.setFont(new java.awt.Font("SansSerif", 1, 16));
		lblLSPMSM.setPreferredSize(new Dimension(394, 24));
		lblLSPMSM.setText("Master Maintenance Generate System Tool");
		String icon = "images" + System.getProperty("file.separator") +"icon.png";
		lblLSPMSM.setIcon(new ImageIcon(icon));
		lblNTTAT.setFont(new java.awt.Font("Arial", 1, 11));
		lblNTTAT.setText("Version 0.1");
		lblNTTAT.setHorizontalAlignment(SwingConstants.CENTER);

		lblAddress.setText("Copyright © 2008 Vectz Corp.");

		lblAddress.setHorizontalAlignment(SwingConstants.CENTER);
		layoutPicture.setHgap(0);
		layoutPicture.setVgap(0);
		pnlContent.setPreferredSize(new Dimension(439, 182));
		// pnlAbout.add(pnlButton, BorderLayout.SOUTH);
		// pnlButton.add(cmdClose, null);

		pnlContent.add(pnlPicture, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,
				GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
						0, 0, 0, 0), 0, 0));
		pnlPicture.add(lblPicture, null);
		pnlContent.add(lblLSPMSM, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
				GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(
						12, 19, 0, 34), 8, 4));
		pnlContent.add(btnClose, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,
				GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(9,
						169, 13, 115), 6, 0));
		pnlContent.add(lblAddress, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,
				GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE,
				new Insets(0, 1, 0, 18), 92, 7));
		pnlContent.add(lblNTTAT, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
				GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
						9, 49, 1, 0), 96, 7));
		this.getContentPane().add(pnlAbout, BorderLayout.SOUTH);
		this.getContentPane().add(pnlContent, BorderLayout.WEST);

		btnClose.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				doOK();
			}
		});

		this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setSize(new Dimension(429, 169));
		SwingUtil.center(this);
		// AnhDV add 2008-07-09
		getRootPane().setDefaultButton(btnClose);
		this.setAlwaysOnTop(true);
		this.setVisible(true);
	}

	public void doOK() {
		this.dispose();
	}
}
